extends Area2D

var slime_speed : float = -50
var is_dead :bool = false

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:
	if not is_dead:
		position = position + Vector2(slime_speed, 0) * delta
	if position.x < -260:
		queue_free()


func _on_body_entered(body: Node2D) -> void:
	if body is CharacterBody2D:
		body.game_over()


func _on_area_entered(area: Area2D) -> void:
	if area.is_in_group("bullet"):
		area.queue_free()
		is_dead = true
		get_tree().current_scene.scoer += 1
		$AnimatedSprite2D.play("deth")
		await get_tree().create_timer(0.6).timeout
		queue_free()
